package backend.majiong.yaku.yaku;

import backend.MainGame;
import backend.majiong.Pai;
import backend.majiong.Player;
import backend.majiong.yaku.AbstractYaku;
import backend.majiong.yaku.HandCombo;

public class PinFu extends AbstractYaku {


    @Override
    public boolean checkYaku(Player player, HandCombo combo, MainGame mainGame) {
        if (!combo.getIsMengQing()) {
            return false;
        }
        if (combo.getKeZi().size() > 0 || combo.getGangZi().size() > 0) {
            return false;
        }
        if (combo.getDuiZi().isSanYuan() || combo.getDuiZi().equals(player.getSelfWind())
                || combo.getDuiZi().equals(mainGame.getTableWind())) {
            return false;
        }
        Pai addPai = combo.getAddPai();
        for (Pai pai : combo.getSunZi()) {
            if (addPai.equals(pai) && pai.getNextPai().getNextPai().getNextPai() != null) {
                return true;
            }
            if (addPai.equals(pai.getNextPai().getNextPai()) && pai.getBeforePai() != null) {
                return true;
            }
        }
        return false;
    }

    @Override
    public String getYakuName() {
        return "平胡";
    }

    @Override
    public Integer getYakuNum(boolean isMenQing) {
        return 1;
    }

}
